package ca.unbc.cpsc672.fuzzy.function;

public class Gaussian extends MembershipFunction {
	private static final String MU = "Mu";
	private static final String SIGMA = "Sigma";

	public Gaussian(String label, double mu, double sigma) {
		super(label);
		addParamenter(MU, mu);
		addParamenter(SIGMA, sigma);
	}

	private double calcGaussian(double x) {
		double ret = (x - getParamenter(MU)) / getParamenter(SIGMA);
		ret = Math.exp(-ret * ret / 2);
		return ret;
	}

	@Override
	public double getCenter() {
		return getParamenter(MU);
	}

	// LaTeX code
	// y(x) = e^{-\frac{(x-\mu )^{2}}{2\sigma ^{2}}}
	@Override
	protected String getImageName() {
		return "gaussian.gif";
	}

	@Override
	protected double calcFunction(double x) {
		return calcGaussian(x);
	}
}
